import http from './http.js';
import store from '../store/index.js'



//根据配置代码获取参数配置
export function getWebConfig(code) {
    return new Promise(
        (resolve, reject) => {
            const hasInitWebConfig =  store.getters.hasInitWebConfig;


            if (hasInitWebConfig) {
                resolve(store.state.webConfig);

            } else {
                let url = `/open/plugs/read/webConfig`
                http.get(url).then(response => {
                    if (response.code === 0) {

                        //将配置文件写入到vuex
                        store.commit("setWebConfig", response.data.result);
                        resolve(response.data.result);
                    } else {
                        alert("配置文件读取失败");
                    }

                });

            }


        });
}


//员工登录方法
export function operatorLogin(param) {
    return new Promise(
        (resolve, reject) => {
            http.post("/open/auth/login", param).then(response => {
                resolve(response)
            });
        });
}

